
.PHONY: deploy 
include .env
# 公共变量
SSH_CMD =echo $(SSH_HOST) && ssh -o StrictHostKeyChecking=no -i ${SSH_KEY} $(SSH_HOST)
PROJECT_NAME = $(notdir $(CURDIR))
HOME_DIR =~/$(PROJECT_NAME)

run:
	@echo "当前镜像:" 
	@echo $(IMAGE_NAME)
	@  docker compose -f deploy/docker-compose.yml  --env-file .env  up

deploy: 
	scp  -i ${SSH_KEY}  -r . $(SSH_HOST):$(HOME_DIR)
	$(SSH_CMD) "cd $(HOME_DIR)/deploy &&  docker compose pull && docker compose up -d"
	make ps
	make log


# 容器相关

log:
	$(SSH_CMD) "cd $(HOME_DIR)/deploy && docker compose logs -f"

ps:
	$(SSH_CMD) "cd $(HOME_DIR)/deploy && docker compose ps"

ps-a:
	$(SSH_CMD) "docker ps "


## SSH 相关
ssh:
	@$(SSH_CMD) 

sh:
	@$(SSH_CMD) $(cmd)	

ssh-clear:
	ssh-keygen -R 8.138.254.185



## 工具类
ip:
	@$(SSH_CMD) "curl -s ip.me"
